<template>
  <div class="page-container-padding">
    <!-- 查询条件 -->
    <div>
      <el-select v-model="active" size="mini">
        <el-option value="0" label="全部" />
        <el-option value="1" label="有效" />
        <el-option value="-1" label="无效" />
      </el-select>
      <el-button
        style="margin-left: 6px"
        type="primary"
        size="mini"
        :loading="dataLoading"
        @click="getInfos"
      >
        查询
      </el-button>
      <el-button
        style="margin-left: 6px"
        size="mini"
        :loading="dataLoading"
        @click="toExportFile"
      >
        导出Excel
      </el-button>
    </div>
    <!-- 表格显示 -->
    <div style="margin-top: 8px">
      <el-table border stripe :data="infoList">
        <el-table-column prop="admin_name" label="姓名" />
        <el-table-column prop="phone" label="联系电话" />
        <el-table-column prop="department" label="单位" show-overflow-tooltip />
        <el-table-column
          prop="position_name"
          label="职务"
          show-overflow-tooltip
        />
        <el-table-column
          prop="introducer"
          label="推荐人"
          show-overflow-tooltip
        />
      </el-table>
    </div>
  </div>
</template>
<script>
  import { GetRoleUserInfos } from '@/api/systemManage/userInfo'
  export default {
    data() {
      return {
        pageRole: 250, // 业务人员
        active: '0',
        infoList: [],
        dataLoading: false,
      }
    },
    mounted() {
      this.getInfos()
    },
    methods: {
      getInfos() {
        this.dataLoading = true
        GetRoleUserInfos(this.pageRole, this.active).then((res) => {
          this.infoList = res.data
          this.dataLoading = false
        })
      },

      toExportFile() {
        this.dataLoading = true
        GetRoleUserInfos(this.pageRole, this.active, 1).then((res) => {
          let a = document.createElement('a')
          a.href = res.data.file_url
          a.style.display = 'none'
          document.body.appendChild(a)
          a.click()
          document.body.removeChild(a)
          this.dataLoading = false
        })
      },
    },
  }
</script>
<style scoped lang="scss"></style>
